export const USER_CONFIG = {
  gridConfig: [
    {
      label: '订单ID',
      prop: 'id',
      width: 80,
      resizable: false
    },
    {
      label: '订单号',
      prop: 'order_no',
      width: 180,
      resizable: false
    },
    {
      label: '商品',
      prop: 'goods',
      className: 'table-media-column table-media-column--flex-column',
      resizable: false,
      width: '350',
      showOverflowTooltip: false,
      render: (h, scope) => {
        var skus = scope.row.goods
        var raw = []
        for (var i = 0, size = skus.length; i < size; i++) {
          var goods = skus[i]
          var template = h('em-goods-card', {
            attrs: {
              num: goods.goods_number,
              price: goods.price,
              desc: goods.skuName,
              title: goods.name,
              thumb: goods.thumb,
              originPrice: goods.originPrice
            }
          })
          raw.push(template)
        }
        return raw
      }
    },
    {
      label: '订单价格（元）',
      prop: 'amount',
      resizable: false,
      align: 'right'
    },
    {
      label: '优惠金额（元）',
      prop: 'discount',
      resizable: false,
      align: 'right'
    },
    {
      label: '应付/实付金额（元）',
      prop: 'pay',
      resizable: false,
      align: 'right'
    },
    {
      label: '使用积分',
      prop: 'pay_credit',
      resizable: false,
      align: 'right'
    },
    {
      label: '运费（元）',
      prop: 'express_price',
      resizable: false,
      align: 'right'
    },
    {
      label: '支付信息',
      prop: 'trade',
      resizable: false,
      align: 'right',
      render: (h, params) => {
        var trade = params.row.trade
        if (trade) {
          return h('div', {}, [
            '交易号：' + trade.trade_no,
            '交易金额：' + trade.total,
            '现金金额：' + trade.cash,
            '积分金额：' + trade.credit
          ])
        } else {
          return h(
            'el-tag',
            {
              props: {
                size: 'mini',
                type: 'primary'
              }
            },
            '无'
          )
        }
      }
    },
    {
      label: '收件信息',
      prop: 'address',
      align: 'right',
      render: (h, params) => {
        var address = params.row.address
        return address && h('div', {}, ['收件人：' + address.name, '联系电话：' + address.mobile])
      }
    },
    {
      label: '下单时间',
      prop: 'created_at',
      align: 'right',
      format: {
        type: 'rowtime'
      }
    },
    {
      label: '订单状态',
      prop: 'status',
      align: 'right',
      render: (h, params) => {
        var status = params.row.status
        return h(
          'el-tag',
          {
            props: {
              size: 'mini',
              type: status.class
            }
          },
          status.text
        )
      }
    }
  ],
  // crud的操作按钮配置，基础按钮有添加、修改、删除、查看，还可以配置扩展按钮
  gridBtnConfig: {
    create: false,
    update: false,
    delete: false,
    view: true
  },
  // crud的操作按钮配置，基础按钮有添加、修改、删除、查看，还可以配置扩展按钮
  gridHandles: [
    {
      name: '查看',
      emitName: 'view'
    }
  ]
}
